<template>
	<view>
		<!-- 滑动操作 -->
		<uni-swipe-action>
			<!-- 画家列表 -->
			<uni-list class="list-news" v-for="(item,index) of listWorking" :key="index">
				<view class="search">
					<uni-swipe-action-item>
						<image :src="item.headerImage" mode="aspectFit" class="image-news"></image>
						<view class="time-news">收藏时间: {{item.createTime}}</view>
						<view class="title-news">作品：{{item.titles}}</view>
					</uni-swipe-action-item>
				</view>
			</uni-list>
		</uni-swipe-action>
		
		<view class="bottom"></view>
		<commonUserTabBar :currentTab="currentTab"></commonUserTabBar>
	</view>
</template>

<script>
import global from '@/global.js'

export default {
data() {
	return {
		listWorking:[],
		//当前选项卡
		currentTab:'/pages/workingList/collectionWorkingList',
		pageIndex: 1,
		pageSize: 10,
		totalCount:0,
		hasMore: true,
	}
	
},
    methods: {
      init(){
		  var token = uni.getStorageSync("token")
		  var phone = uni.getStorageSync("phone")
		  console.log("caches get  token value :  ", token)
		  console.log("caches get  phone value :  ", phone)
		  uni.request({
		  	url: global.baseUrl + 'api/userCollec/list', // 接口地址
		  	method: 'get',
		  	dataType: "json",
			data:{
				collectoonType: 4,
				pageIndex: this.pageIndex,
				pageSize: this.pageSize,
				orderBy: "id:DESC",
				hasMore: true
			},
		  	header: {
				'X-Token': token
		  	},
		  	success: (res) => {
		  		if (res.data.code == 0) {
		  			this.listWorking=res.data.data
		  		} 
		  	},
		  	fail: (error) => {
		  		console.log(error)
		  	}
		  })
		  
	  }
	},
	onLoad() {
		this.init();
	},
	onReachBottom(){
		    console.log('触底了')
			    if (this.pageIndex * this.pageSize >= this.totalCount) {
					uni.showToast({
						title: '没有更多数据了',
						icon: 'none',
						duration: 1000
					});
					setTimeout(() => {
						uni.hideLoading()
					}, 500)
				} else {
					if (this.pageIndex <= this.pageIndex - 1) {
						setTimeout(() => {
							uni.hideLoading()
						}, 500)
					} else {
						uni.showLoading({
							title: '加载中'
						});
						this.pageIndex++
						this.init()
					}
					setTimeout(() => {
						uni.hideLoading()
					}, 500)
				}
			},
		// 页面下拉时触发，与 onLoad 等生命周期函数平级
		onPullDownRefresh() {
		    console.log('refresh');
		    setTimeout(function () {
		        // 操作完成时，必须结束下拉刷新，否则一直会有 loading 标志
		        uni.stopPullDownRefresh();
		    }, 1000);
		}
}
</script>

<style scoped>
	.list-news {
		width: 94%;
		margin: auto;
	}
 
	.search {
		margin-top: 10rpx;
		position: relative;
		height: 210rpx;
	}
 
	.image-news {
		display: inline-block;
		width: 200rpx;
		height: 200rpx;
	}
 
	.time-news {
		position: absolute;
		right: 10rpx;
		top: 10rpx;
	}
	
	.time-browseNum{
		position: absolute;
		right: 10rpx;
		top: 60rpx;
	}
 
	.title-news {
		width: 480rpx;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		position: absolute;
		bottom: 10rpx;
		left: 220rpx;
	}
</style>
